
<template>
<span class="opera_dir-wrapper">
  <component v-if='components_name' :is='components_name' :detail_info="detail_info" :_id="_id"
             :wrapper_name="wrapper_name" :col="col"></component>
</span>
</template>
<script type="text/ecmascript-6">
    import tool from 'src/util/tool';
    import util from '_util/index';
    import logic from '_logic';
    import in_array from 'in_array';

    import Model from './Model.vue';
    import Trosp from './Trosp.vue';
    import Refundorders from './Refundorders.vue';
    //仓库列表
    import Warehouse from './Warehouse.vue'

    //仓库规格商品
    import Whprod from './Whprod'

    //仓库商品
    import WarehouseTopProduct from './WarehouseTopProduct'

    //场景列表
    import myTr from './Tr'

    //提现列表
    import Withdraw from './Withdraw.vue'

    import Attr from './Attr.vue';
    import TopProduct from './TopProduct.vue';
    import Product from './Product.vue';
    import Trodetail from './Trodetail.vue';
    import auth_tpl from './auth_tpl.vue';

	//渠道
	import Qd from './Qd.vue'


    export default {
        data() {
            return {
                detail_info: null,
                auths: null,
            }
        },
        components: {
            Model,
            auth_tpl,myTr,
            Trosp, Refundorders
            , Attr, TopProduct, Product, Trodetail, Warehouse,
            Whprod,
            WarehouseTopProduct,
            Withdraw,Qd
        },
        methods: {
            myinit(){
                this.setDetailInfo();
            },
//            setAuth() {
//                this.auths = util.modelFn('Auth', 'get_type_auth', this, 'cell_op');
//                Object.keys(this.col.btns).forEach(flag=> {
//                    if(!this.is_admin&&!this.auths.contains(flag)) {
//                        delete this.col.btns[flag];
//                    }
//                });
//            },
            setDetailInfo(){
                switch (this.ctl) {
                    case 'cache_models':
                        this.detail_info = logic.detail.getDetail(this, this._id, 'name');
                        break;
                }
            },
        },
        computed: {
            wrapper_name(){
                return `opera_${this.ctl}-wrapper`
            },
            ctl(){
                return this.$route.query.ctl;
            },
            _id(){
                return this.col.val;
            },
            is_admin(){
                return util.is_admin(this);
            },
            components_name() {
                let arr = ['Model', 'Trosp', 'Trodetail', 'Refundorders', 'Attr', 'auth_tpl', 'TopProduct', 'Product', 'Warehouse','WarehouseTopProduct','Whprod','Tr','Withdraw','Qd']
                if (in_array(this.ctl, arr)){
                    let name = this.ctl;
                    switch (this.ctl) {
                        case 'Tr':
                            name='myTr'

                    }
                    return name;
                }
                else
                    return null;
            }
        },
        watch: {
            _id: function (val, old) {
                if (val && val != old) {
                    this.myinit();

                }
            },
            ctl: function (val, old) {
                if (val != old) {
//                    this.setAuth();
                }
            }
        },

        props: ['col'],
        created() {
            this.myinit();
//            this.setAuth();
        },
    }
</script>
<style rel="stylesheet/less" lang="less">@dir: "header/";</style>
